<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>


<style type="text/css">
    .l-table-edit {font-size: 12px;margin: auto;}
 	.l-table-edit-td{ padding:4px;}
    .l-button-submit,.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
    .l-verify-tip{ left:230px; top:120px;}
    .error{color:red}
</style>
<table cellpadding="0" cellspacing="0" class="l-table-edit">
	<tr>
			<td align="right" class="l-table-edit-td">
				滚动图片1:
			</td>
			<td align="left" class="l-table-edit-td">
				<form id="upload_img_form1" enctype="multipart/form-data" method="post" action="/misc/product/uploadImg.htm">
					<input type="file" onchange="uploadImg(this,1);return false;" style="width: 200px;"  title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagef1" id="imagef1"/>
					<a href="javascript:;" target="_blank" onclick="previewImg('image1');">预览</a>
				</form>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">
				滚动图片2:
			</td>
			<td align="left" class="l-table-edit-td">
				<form id="upload_img_form2" enctype="multipart/form-data" method="post" action="/misc/product/uploadImg.htm">
					<input type="file" onchange="uploadImg(this,2);return false;" style="width: 200px;"  title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagef2" id="imagef2"/>
					<a href="javascript:;" target="_blank" onclick="previewImg('image2');">预览</a>
				</form>
			</td>
			<td align="left"></td>
		</tr>
		
		<tr>
			<td align="right" class="l-table-edit-td">
				滚动图片3:
			</td>
			<td align="left" class="l-table-edit-td">
				<form id="upload_img_form3" enctype="multipart/form-data" method="post" action="/misc/product/uploadImg.htm">
					<input type="file" onchange="uploadImg(this,3);return false;" style="width: 200px;"  title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagef3" id="imagef3"/>
					<a href="javascript:;" target="_blank" onclick="previewImg('image3');">预览</a>
				</form>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">
				滚动图片4:
			</td>
			<td align="left" class="l-table-edit-td">
				<form id="upload_img_form4" enctype="multipart/form-data" method="post" action="/misc/product/uploadImg.htm">
					<input type="file" onchange="uploadImg(this,4);return false;" style="width: 200px;"  title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagef4" id="imagef4"/>
					<a href="javascript:;" target="_blank" onclick="previewImg('image4');">预览</a>
				</form>
			</td>
			<td align="left"></td>
		</tr>
		
		<tr>
			<td align="right" class="l-table-edit-td">
				滚动图片5:
			</td>
			<td align="left" class="l-table-edit-td">
				<form id="upload_img_form5" enctype="multipart/form-data" method="post" action="/misc/product/uploadImg.htm">
					<input type="file" onchange="uploadImg(this,5);return false;" style="width: 200px;"  title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagef5" id="imagef5"/>
					<a href="javascript:;" target="_blank" onclick="previewImg('image5');">预览</a>
				</form>
			</td>
			<td align="left"></td>
			
		</tr>
</table>
<form name="saveForm" method="post" action="/misc/product/saveProduct.htm" id="saveForm">
	<input name="id" type="hidden" id="id" value="${product.id}" />
	<input name="image1" type="hidden" id="image1" value="${product.image1}"/>
	<input name="image2" type="hidden" id="image2" value="${product.image2}"/>
	<input name="image3" type="hidden" id="image3" value="${product.image3}"/>
	<input name="image4" type="hidden" id="image4" value="${product.image4}"/>
	<input name="image5" type="hidden" id="image5" value="${product.image5}"/>
	<table cellpadding="0" cellspacing="0" class="l-table-edit">
		<tr>
			<td align="right" class="l-table-edit-td">
				名字:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="name" type="text" id="name" value="${product.name}" ltype="text" validate="{required:true,minlength:1,maxlength:50}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">排序:</td>
            <td align="left" class="l-table-edit-td"> 
            	<input name="sort" type="text" id="sort" ltype="text" value="${product.sort}"  validate="{number:true}" />
            </td>
            <td align="left"></td>
            
			
		</tr>
	

		
		
		<tr>
			<td align="right" class="l-table-edit-td">
				市场价格:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="priceMarket" type="text" id="priceMarket" value="${product.priceMarket}" ltype="text" validate="{required:true,number:true}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td">
				普通价格:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="priceMin" type="text" id="priceMin" value="${product.priceMin}" ltype="text" validate="{required:true,number:true}" /><span style="color: red;">*</span>
			</td>
			<td align="left"></td>
		</tr>
		
		<tr>
			<td align="right" class="l-table-edit-td" valign="top">
				产品类型:
			</td>
			<td align="left" class="l-table-edit-td">
				<input id="type1" type="radio" name="type" value="01" <c:if test="${product.type=='01'}">checked="checked"</c:if> />
				<label for="type1">
					特价美食
				</label>
				<input id="type2" type="radio" name="type" value="02" <c:if test="${product.type=='02'}">checked="checked"</c:if>/>
				<label for="type2">
					旅游商品
				</label>
				<input id="type3" type="radio" name="type" value="03" <c:if test="${product.type=='03'}">checked="checked"</c:if>/>
				<label for="type3">
					线路推荐
				</label>
			</td>
			<td align="left"></td>
			<td align="right" class="l-table-edit-td" valign="top">
				支付方式:
			</td>
			<td align="left" class="l-table-edit-td">
				<input id="payFrom1" type="radio" name="payFrom" value="01" <c:if test="${product.payFrom=='01'}">checked="checked"</c:if> />
				<label for="payFrom1">
					线上支付
				</label>
				<input id="payFrom2" type="radio" name="payFrom" value="02" <c:if test="${product.payFrom=='02'}">checked="checked"</c:if>/>
				<label for="payFrom2">
					到付
				</label>
			</td>
			<td align="left"></td>
		</tr>
		
        <tr>
            
            <td align="right" class="l-table-edit-td">
				是否可用:
			</td>
			<td align="left" class="l-table-edit-td" colspan="2">
				<input id="enabled1" type="radio" name="enabled" <c:if test="${product.enabled}">checked="checked"</c:if> value="1" />
				<label for="enabled1">
					是
				</label>
				<input id="payFrom2" type="radio" name="enabled" <c:if test="${!product.enabled}">checked="checked"</c:if> value="0" />
				<label for="payFrom2">
					否
				</label>
			</td>
			<td align="left" class="l-table-edit-td">
				提前预定天数:
			</td>
			<td align="left" class="l-table-edit-td">
				<input name="befores" type="text" id="befores" ltype="text" value="${product.befores}" validate="{number:true}" />
			</td>
        </tr>
        <tr>
            <td align="right" class="l-table-edit-td" valign="top">
				点评回复:
			</td>
			<td align="left" class="l-table-edit-td">
				<input id="discommt1" type="radio" name="discommt" <c:if test="${product.discommt=='01'}">checked="checked"</c:if> value="01"  />
				<label for="discommt1">
					允许点评
				</label>
				<input id="discommt2" type="radio" name="discommt" <c:if test="${product.discommt=='02'}">checked="checked"</c:if> value="02" />
				<label for="discommt2">
					允许回复
				</label>
				<input id="discommt3" type="radio" name="discommt" <c:if test="${product.discommt=='03'}">checked="checked"</c:if> value="03" />
				<label for="payFrom2">
					全不允许
				</label>
			</td>
            <td align="left"></td>
            <td align="right" class="l-table-edit-td" valign="top">
				所属公司:
			</td>
			<td align="left" class="l-table-edit-td">
			<%@include file="../company/companyName.jsp" %>
				<%-- <select name="company" id="company">
					<option value="">请选择</option>
					<c:forEach items="${companyModel.list}" var="comp">
						<option value="${comp.id}"
						<c:if test="${product.company==comp.id }">SELECTED</c:if>
						>${comp.name}</option>
					</c:forEach>
				</select> --%>				
			</td>
            <td align="left"></td>
        </tr>
       <tr>
            <td align="right" class="l-table-edit-td">地址:</td>
            <td align="left" class="l-table-edit-td"> 
            	<input name="address" type="text" id="address"  value="${product.address}"  maxlength="100" style="width: 250px;"/>
            </td>
            <td align="left"></td>
            <td align="right" class="l-table-edit-td">是否需要邮寄地址:</td>
            <td align="left" class="l-table-edit-td"> 
            	<input id="need_address1" type="radio" name="needAddress" <c:if test="${product.needAddress}">checked="checked"</c:if> value="1"  />
				<label for="need_address1">
					需要
				</label>
				<input id="need_address2" type="radio" name="needAddress" <c:if test="${!product.needAddress}">checked="checked"</c:if> value="0" />
				<label for="need_address2">
					不需要
				</label>
				
            </td>
       </tr>
        <tr>
            <td align="right" class="l-table-edit-td">是否有发票:</td>
            <td align="left" class="l-table-edit-td" colspan="2"> 
            	<input id="need_invoice1" type="radio" name="needInvoice" <c:if test="${product.needInvoice}">checked="checked"</c:if> value="1"  />
				<label for="need_invoice1">
					有
				</label>
				<input id="need_invoice2" type="radio" name="needInvoice" <c:if test="${!product.needInvoice}">checked="checked"</c:if> value="0" />
				<label for="need_invoice2">
					没有
				</label>
            </td>
            
            <td align="right" class="l-table-edit-td">普通价是否可用:</td>
            <td align="left" class="l-table-edit-td" colspan="3"> 
            	<input id="need_invoice1" type="radio" name="priceComHas" <c:if test="${product.priceComHas}">checked="checked"</c:if> value="1"  />
				<label for="need_invoice1">
					有
				</label>
				<input id="need_invoice2" type="radio" name="priceComHas" <c:if test="${!product.priceComHas}">checked="checked"</c:if> value="0" />
				<label for="need_invoice2">
					没有
				</label>
            </td>
       </tr>
        <tr>
            <td align="right" class="l-table-edit-td">地图:</td>
            <td align="left" class="l-table-edit-td" colspan="4"> 
            	<input type="hidden" id="lng" name="lng" value="${product.lng}"/>
            	<input type="hidden" id="lat" name="lat" value="${product.lat}"/>
            	 <img id="map_url"  src="" />
            </td>
            <td align="left"><a href="javascript:;" onclick="mapSetting();">设置</a></td>
            
       </tr>
		<tr>
            <td align="right" class="l-table-edit-td">公告:</td>
            <td align="left" class="l-table-edit-td" colspan="5"> 
            	<textarea cols="100" rows="4" class="l-textarea"  id="notice" name="notice" style="width:600px" >${product.notice}</textarea>
            </td>
        </tr>
		<tr>
            <td align="right" class="l-table-edit-td">产品经理推荐:</td>
            <td align="left" class="l-table-edit-td" colspan="5"> 
            	<textarea cols="100" rows="4" class="l-textarea" id="recommend" name="recommend" style="width:600px" >${product.recommend}</textarea>
            </td>
        </tr>
		<tr>
            <td align="right" class="l-table-edit-td">产品特色:</td>
            <td align="left" class="l-table-edit-td" colspan="5"> 
            	<textarea cols="100" rows="4" class="l-textarea" id="special" name="special" style="width:600px" >${product.special}</textarea>
            </td>
        </tr>
        <tr>
            <td align="right" class="l-table-edit-td">行程说明:</td>
            <td align="left" class="l-table-edit-td" colspan="5"> 
            	<textarea cols="100" rows="4" class="l-textarea" id="tripInfo" name="tripInfo" style="width:600px" >${product.tripInfo}</textarea>
            </td>
        </tr>
        <tr>
            <td align="right" class="l-table-edit-td">费用说明:</td>
            <td align="left" class="l-table-edit-td" colspan="5"> 
            	<textarea cols="100" rows="4" class="l-textarea" id="feeInfo" name="feeInfo" style="width:600px" >${product.feeInfo}</textarea>
            </td>
        </tr>
        <tr>
            <td align="right" class="l-table-edit-td">重要提示:</td>
            <td align="left" class="l-table-edit-td" colspan="5"> 
            	<textarea cols="100" rows="4" class="l-textarea" id="notify" name="notify" style="width:600px" >${product.notify}</textarea>
            </td>
        </tr>
	</table>
	<br />
	<input type="submit" value="保存" id="Button1" class="l-button l-button-submit" />
	<input type="button" value="取消" class="l-button l-button-test" onclick="javascript:parent.dialog_ae.close();"/>
</form>


<script type="text/javascript">
$(function() {
	
	var toolbars = [['FullScreen','Source','Link','Unlink','Preview','InsertImage','Emotion','Spechars','Bold','Italic',
			'Underline','StrikeThrough','ForeColor','BackColor','JustifyLeft','JustifyCenter','JustifyRight','JustifyJustify',
			'Paragraph','FontFamily','FontSize','ImageNone','ImageLeft','ImageRight','ImageCenter','GMap','Map']];
	var initialStyle = 'body{font-family:"宋体";font-size:12px;}';
	var initArgus = {
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false
	}
	var notice_editor = new baidu.editor.ui.Editor({
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false,
		textarea:'notice'
	});
    notice_editor.render("notice");
    
    var recommend_editor = new baidu.editor.ui.Editor({
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false,
		textarea:'recommend'
	});
    recommend_editor.render("recommend");
    
    var special_editor = new baidu.editor.ui.Editor({
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false,
		textarea:'special'
	});
    special_editor.render("special");
    
    var trip_info_editor = new baidu.editor.ui.Editor({
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false,
		textarea:'tripInfo'
	});
    trip_info_editor.render("tripInfo");
    
    var fee_info_editor = new baidu.editor.ui.Editor({
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false,
		textarea:'feeInfo'
	});
    fee_info_editor.render("feeInfo");
    
    var notify_editor = new baidu.editor.ui.Editor({
		toolbars:toolbars,
		wordCount:false,
		minFrameHeight:50,
		initialStyle: initialStyle,
		elementPathEnabled : false,
		textarea:'notify'
	});
    notify_editor.render("notify");
    
    
    $.metadata.setType("attr", "validate");
	$("#saveForm").validate({
		 errorPlacement: function (lable, element){
             if (element.hasClass("l-textarea")){
                 element.ligerTip({ content: lable.html(), target: element[0] }); 
             }else if (element.hasClass("l-text-field")){
                 element.parent().ligerTip({ content: lable.html(), target: element[0] });
             }else{
                 lable.appendTo(element.parents("td:first").next("td"));
             }
         },
         success: function (lable){
             lable.ligerHideTip();
             lable.remove();
         },
		submitHandler : function(form) {
        	 $(form).ajaxSubmit({
				dataType : 'text',
				cache : false,
				success : function(data) {
					if(IsNull(data)){
						alert("上传图片失败，请重新上传！");
					}else{
						parent.grid_ae.loadData();
						parent.dialog_ae.close();
					}
					
				},
				error : function(err) {
				//	alert(err);
				}
			});
			return false;
			
			
		}
	});
	if(!IsNull('${product.lng}'))
	$("#map_url").attr("src","http://api.map.baidu.com/staticimage?center=${product.lng},${product.lat}&zoom=16&width=420&height=240&markers=${product.lng},${product.lat}");
//	$("#form1").ligerForm();
});

function uploadImg(self,imagex){
	var filepath = $(self).val();
	var extStart = filepath.lastIndexOf(".");
	var ext = filepath.substring(extStart, filepath.length).toUpperCase();
	if (ext != ".PNG" && ext != ".JPG" && ext != ".JPEG" && ext != ".GIF") {
		alert("图片限于png,jpeg,jpg,gif格式");
		return;
	}
	$("#upload_img_form"+imagex).ajaxSubmit({
		dataType : 'json',
		cache : false,
		success : function(data) {
			$("#image"+imagex).val(data.imageServer+data.imageUrl);
		},
		error : function(err) {
			alert(err);
		}
	});
	return false;
}

function previewImg(imageId){
	var img_url = $("#"+imageId).val();
	if(!IsNull(img_url)){
		window.open(img_url);
	}else{
		alert("没有图片，请上传！");
	}
}
var mapsetDialog;
function mapSetting(){
	mapsetDialog = $.ligerDialog.open({ height: 500,width:600, url: "/thirdparty/ueditor/dialogs/map/mapCoolsk.html", isResize: false ,modal:true,title:'设置地图'});
}
</script>
